Adding some more judges, here and there.
[andmenj-acm.git] / lib / Mi manual de algoritmos / version_maraton_suramericana_2008 / src / number_theory / criba.cpp
blob3cf78e5302d6943d8776446df5a013019e5ee801
1 #include <iostream>
3 const int SIZE = 1000000;
5 //criba[i] = false si i es primo
6 bool criba[SIZE+1];
8 void buildCriba(){
9 memset(criba, false, sizeof(criba));
11 criba[0] = criba[1] = true;
12 for (int i=4; i<=SIZE; i += 2){
13 criba[i] = true;
15 for (int i=3; i*i<=SIZE; i += 2){
16 if (!criba[i]){
17 for (int j=i*i; j<=SIZE; j += i){
18 criba[j] = true;